#include "Socket.hpp"
#include "header.h"

namespace xww
{

Socket::Socket()
{
    _fd = socket(AF_INET, SOCK_STREAM, 0);
    if (_fd < 0)
    {
        perror("socket");
    }
}

Socket::Socket(int fd)
: _fd(fd)
{
    if (_fd < 0)
    {
        perror("socket");
    }
}

Socket::~Socket()
{
    close(_fd);//关闭socket文件描述符
}

void Socket::shutdownWrite()
{
    shutdown(_fd, SHUT_WR);//关闭写端
}

}